import React from 'react';
import { connect } from 'dva';
import { ListView, Icon, Badge } from 'antd-mobile';
import avatar from '../../../../../../framework/utils/avatar';
import styles from './partTimeMessageListItem.css';
import date from '../../../../../../framework/utils/date';
import cutStr from '../../../../../../framework/utils/cutStr';

const PartTimeMessageListItem = ({
  item={},
  onViewPage = () => {},
  onCloseMessage = () => {},
}) => {

  // console.log('item',JSON.stringify(item));
  // const publishTime = date.delta(item.publishTime)

  let headerTitle = [`${styles.headerTitle}`];
  if(item.readed == 1){
    headerTitle = [`${styles.headerTitleBg}`];
  }

  const handleCloseMessage = (item) => {
    if(item.readed == 0){
      onCloseMessage(item.id);
    }
  }

  return (
    <div className={styles.content}>
      <div className={styles.header}>
        <div className={headerTitle.join(' ')}>消息</div>
      </div>
      <span className={styles.titleBtn} onClick={() => onViewPage(item)}>
        {item.type == 'SETTLED' ? '查看钱包' : '查看该兼职'}
      </span>
      <div className={styles.messageBody} onClick={() => handleCloseMessage(item)}>
        <div className={styles.messageTitle}>
          <span className={styles.titleText}>
            {item.jobTitle ? cutStr.cutString(item.jobTitle, 22) : ''}
          </span>
        </div>
        <div className={styles.question}>

          <div className={styles.questionText}>
            {item.content}
          </div>
        </div>
      </div>
      <div className={styles.dateTime}>
        {item.createdDate ? date.delta(item.createdDate) : ""}
      </div>
    </div>
  );
};

PartTimeMessageListItem.propTypes = {
};

export default connect()(PartTimeMessageListItem);
